<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/2
 * Time: 15:43
 */

namespace common\business\org;


use common\business\DbHandler;
use common\models\OrgTree;
use common\result\ActionResult;

class OrgTreeApiHandler extends DbHandler
{
    /**
     * @param $obj OrgTree
     * @return ActionResult
     */
    public function createOrgTree($obj){
        return $this->create($obj);
    }

    /**
     * @param OrgTree $obj
     * @return ActionResult
     */
    public function updateOrgTree($obj){
        $oldObj = OrgTree::findOne([
            'id' => $obj->id,
        ]);
        return $this->update($obj, $oldObj, [
            'name',
            'number',
            'display_name',
            'parent_id',
            'parent_number',
            'qywx_id',
            'parent_qywx_id',
            'qywx_name',
            'qywx_order',
            'memo',
            'hr_id',
            'mdm_id',
            'parent_mdm_id',
            'kd_id',
            'parent_kd_id',
            'root',
            'lft',
            'rgt',
            'lvl',
            'icon',
            'icon_type',
            'active',
            'selected',
            'disabled',
            'readonly',
            'visible',
            'collapsed',
            'movable_u',
            'movable_d',
            'movable_l',
            'movable_l',
            'removable',
            'removable_all',
        ]);
    }
}